/**
 * @Author : JiGuangJie
 * @Date : 2022/9/30
 * @Time : 10:01
 * @Version : 1.0.0
 * @Description :
 */
import serve from 'rollup-plugin-serve';
import livereload from 'rollup-plugin-livereload';
import template from 'rollup-plugin-generate-html-template';
import typescript2 from 'rollup-plugin-typescript2';
import commonjs from '@rollup/plugin-commonjs';
import { nodeResolve } from '@rollup/plugin-node-resolve';
import nodePolyfills from 'rollup-plugin-polyfill-node';
import postcss from 'rollup-plugin-postcss';
import json from '@rollup/plugin-json';
import { name } from './package.json';

const extensions = [
    '.mjs', '.json'
];

const devConfig = {
    input: './example/index.ts',
    context: 'window',
    watch: {
        include: [
            'src/**',
            'example/**'
        ]
    },
    output: {
        file: './dist/index.js',
        format: 'umd',
        name: `${ name }`,
        // external: [],
        globals: {},
        extend: true
    },
    plugins: [
        json(),
        postcss(),
        nodePolyfills(),
        nodeResolve({ browser: true, preferBuiltins: true}),
        commonjs(),
        typescript2(),
        template({
            template: './example/index.html',
            target: './dist/index.html'
        }),
        livereload('dist'),
        serve({
            open: false,
            contentBase: ['dist'],
            port: 30000
        })

    ],
    external: []
};

export default devConfig;
